package cn.webrx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Reg12 {
    public static void main(String[] args) {
        String str = """
                <div>myjava</div>java19
                <div>myjava99</div>
				<div>hello</div><div>java 15</div><div><p>java 15</p><span>java 8</p><div>my java 16</div><div>javascript</div></div>
				""";
        System.out.println(str);



        //将<div>标签中的java替换为abc  replace("java","abc")
        Pattern p = Pattern.compile("(<div>[a-z0-9\s]*?)(java)([a-z0-9\s]*?</div>)",2);
        Matcher m = p.matcher(str);

        String t = m.replaceAll("$122$3");
        System.out.println(t);
    }

    public static void tem(String[] args) {
        String str = """
                <div>myjava</div>
                <div>myjava99</div>
				<div>hello</div><div>java 15</div><div><p>java 15</p><span>java 8</p><div>my java 16</div><div>javascript</div></div>
				""";
        System.out.println(str);


        Pattern p = Pattern.compile("<div>([a-z0-9\s]*?java[a-z0-9\s]*?)</div>",2);
        Matcher m = p.matcher(str);
        while(m.find()){
            System.out.println(m.group(1));
        }




    }
}
